package com.macro.mall.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.PmsSkuStock;
import com.macro.mall.model.SmsFlashPromotion;
import com.macro.mall.service.PmsPanicBuyingService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class PmsPanicBuyingController {
    @Autowired
    private PmsPanicBuyingService pmsPanicBuyingService;


    @Operation(summary = "根据商品编号及编号模糊搜索sku库存")
    @RequestMapping(value = "/panicbuy/{pid}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<List<PmsSkuStock>> panicbuy(@PathVariable Long pid) {
        List<PmsSkuStock> skuStockList = pmsPanicBuyingService.getList(pid);
        return CommonResult.success(skuStockList);
    }


    @Operation(summary = "判断状态是否开启")
    @RequestMapping(value = "/stateid/{pid}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<SmsFlashPromotion> stateid(@PathVariable Long pid) {
        SmsFlashPromotion skuStockList = pmsPanicBuyingService.stateid(pid);
        return CommonResult.success(skuStockList);
    }

}
